/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PInicio.java
 *
 * Created on Jun 16, 2012, 7:00:04 PM
 */
package Vistas;

import sha.pkg1.SHA1;
import sha.pkg1.fnApoyo;

/**
 *
 * @author Stev
 */
public class PInicio extends javax.swing.JPanel {
    SHA1 sha= new SHA1();
    fnApoyo ayudante= new fnApoyo();
  
    /** Creates new form PInicio */
    public PInicio() {
        initComponents();
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        texto_Hash = new javax.swing.JTextArea();
        botonHashear = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        Mensaje = new javax.swing.JTextArea();

        setMaximumSize(new java.awt.Dimension(433, 291));
        setMinimumSize(new java.awt.Dimension(433, 291));
        setPreferredSize(new java.awt.Dimension(433, 291));

        texto_Hash.setColumns(20);
        texto_Hash.setRows(5);
        jScrollPane1.setViewportView(texto_Hash);

        botonHashear.setText("Listo");
        botonHashear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonHashearActionPerformed(evt);
            }
        });

        Mensaje.setColumns(20);
        Mensaje.setRows(5);
        jScrollPane2.setViewportView(Mensaje);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 364, Short.MAX_VALUE))
                .addContainerGap(34, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(154, Short.MAX_VALUE)
                .addComponent(botonHashear, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(147, 147, 147))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(37, Short.MAX_VALUE)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(botonHashear)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18))
        );
    }// </editor-fold>//GEN-END:initComponents
  
    
    private void botonHashearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonHashearActionPerformed

        String texto =Mensaje.getText();
       
        StringBuilder textoConv[]= new StringBuilder[2];
        textoConv=  sha.rellenar_448Mod512(texto);
        
        System.out.println("Rellenado Binario: "+textoConv[0]);
        System.out.println("Rellenado Hex: "+textoConv[1]);
     
        StringBuilder[] bloques= ayudante.creaBloque(textoConv[0], 512); 
        for(int i=0; i< bloques.length;i++){
        System.out.println("Bloque "+(i+1)+ ": "+bloques[i]);
      }
        
       System.out.println("Código hash: "+sha.rondas(bloques[0]));
    
      
    }//GEN-LAST:event_botonHashearActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea Mensaje;
    private javax.swing.JButton botonHashear;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea texto_Hash;
    // End of variables declaration//GEN-END:variables
}
